<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Helsinki
  Date: 2022/8/18
  Time: 19:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<!-- 网页使用的语言 -->
<html lang="zh-CN">
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的浏览器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport视口：网页可以根据设置的宽度自动进行适配，在浏览器的内部虚拟一个容器，容器的宽度与设备的宽度相同。
    width: 默认宽度与设备的宽度相同
    initial-scale: 初始的缩放比，为1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>用户信息管理系统</title>

    <!-- 1. 导入CSS的全局样式 -->
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>
    <script>
        onload = function () {
            var checkAll = document.getElementById("selectAll")
            checkAll.onclick = function () {
                var inputs = document.getElementsByTagName("input")
                for (i = 0; i < inputs.length; i++) {
                    inputs[i].checked = this.checked
                }
            }
            var checkForm = document.getElementById("checkTable")
            var delSelectButton = document.getElementById("delSelectButton")
            delSelectButton.onclick = function () {
                checkForm.submit()
                
            }
        }
    </script>
</head>
<body>
<div class="container">
    <h3 style="text-align: center">用户信息列表</h3>
    <div class="row">
        <div class="col-md-9">
            <form class="form-inline">
                <div class="form-group">
                    <label for="exampleInputName2">姓名</label>
                    <input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe">
                </div>
                <div class="form-group">
                    <label for="exampleInputEmail2">籍贯</label>
                    <input type="email" class="form-control" id="exampleInputNavite2"
                           placeholder="jane.doe@example.com">
                </div>
                <div class="form-group">
                    <label for="exampleInputEmail2">邮箱</label>
                    <input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com">
                </div>
                <button type="submit" class="btn btn-default">查询</button>
            </form>
        </div>
        <div class="col-md-3" style="float: right">
            <button style="float: right;margin-right: 5px" type="button" class="btn btn-primary">添加联系人</button>
            <button style="float: right;margin-right: 5px" type="button" class="btn btn-primary" id="delSelectButton">删除选中</button>
        </div>
    </div>
    <div style="margin-top: 10px">
        <form action="${pageContext.request.contextPath}/DelSelectedServlet" method="post" id="checkTable">
            <table border="1" class="table table-bordered table-hover">
                <tr class="success">
                    <th><input type="checkbox" id="selectAll"/></th>
                    <th>编号</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>年龄</th>
                    <th>籍贯</th>
                    <th>QQ</th>
                    <th>邮箱</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${list}" var="user">
                    <tr>
                        <td><input type="checkbox" name="cid" value="${user.uId}"/></td>
                        <td>${user.uId}</td>
                        <td>${user.uName}</td>
                        <td>${user.gender}</td>
                        <td>${user.age}</td>
                        <td>${user.navite}</td>
                        <td>${user.qq}</td>
                        <td>${user.email}</td>
                        <td><a class="btn btn-default btn-sm"
                               href="${pageContext.request.contextPath}/ShowUserServlet?id=${user.uId}">修改</a>&nbsp;
                            <a class="btn btn-default btn-sm"
                               href="${pageContext.request.contextPath}/DeleteUserServlet?id=${user.uId}">删除</a></td>
                    </tr>
                </c:forEach>
                <tr>
                    <td colspan="8" align="center"><a class="btn btn-primary"
                                                      href="${pageContext.request.contextPath}/add.jsp">添加联系人</a></td>
                </tr>
            </table>
        </form>
    </div>
</div>
</body>
</html>
